import api from '../../api/index';
import config from '@/assets/config.json';

const state = {
	userInfo:{
		id:'',
		name:''
	}
}
const mutations = {

}
const getters = {
	
}
const actions = {
	getUser({ rootState, commit }, id) { // 获取用户信息
		return new Promise((resolve, reject) => {
			api.get(`${config.https.api}/demo/user`)
				.then(data => {
					if (data.data&&data.data.data) {
						// commit('setUserInfo', data.data.data, { root: true });
						resolve(data.data.data);
					}
				}).catch((err) => {
					console.log(err);
				});
		});
	},
	// addExhibitionFollower({ rootState, commit }, opt) { // 展会产品
	// 	return new Promise((resolve, reject) => {
	// 		api.post(`${config.https.api}/api/v1/exhibition/follow`, opt, rootState.header).then(data => {
	// 			if (data.data) {
	// 				resolve(data.data);
	// 			}
	// 		}).catch((err) => {
	// 			console.log(err);
	// 		});
	// 	});
	// },
	getNumber({ rootState, commit }, num) {			//模拟异步调接口
		// console.log(rootState.userInfo);
		return new Promise((resolve, reject) => {
			setTimeout(() => {
				resolve(num + 1);
			}, 1000)
		})
	}
}
export default {
	namespaced: true,
	state,
	actions,
	mutations,
	getters,
}